package com.zzxy.springmvc1.controller;

import com.zzxy.springmvc1.po.student;
import com.zzxy.springmvc1.po.StudentExt;
import com.zzxy.springmvc1.po.student;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/stu")
public class StudentController {
    @RequestMapping("/register")
    public String register() {
        return "/user/register";
    }
@RequestMapping("insert")
    public @ResponseBody Student insert(@RequestBody  Student student){
        student.setPassword(student.getPassword()+"qwe");
        student.setUsername(student.setUsername()+"asd");
        return student;
    }

    @RequestMapping("/addStu")
    public String addStu(String username,String password) {
        System.out.println(username);
        System.out.println(password);
        return "/user/userList";
    }

    @RequestMapping("/addStu1")
    public String addStu1(student student) {
        System.out.println(student);
        return "/user/userList";
    }
    @RequestMapping("/addStu2")
    public String addStu1(StudentExt ext) {
        System.out.println(ext);
//        for (Student student : ext.getStudentList()) {
//            System.out.println(student);
//        }
        return "/user/userList";
    }

    @RequestMapping("test")
    public String test() {
        return "forward:/stu/register.do";
    }

    @RequestMapping("test1")
    public String test1() {
        return "redirect:/stu/register.do";
    }
}
